home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1993…ch: Other People's Memory / ADC Developer CD (1993-03) (''Other People's Memory'')_iso / Dev.CD Mar 93.iso / Technical Documentation / Sample Code / DTS.Lib & Samples / DTS.Lib / PPC.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-10-22  |  1.7 KB  |  84 lines  |  [TEXT/MPS ]

  1. /*
  2. ** Apple Macintosh Developer Technical Support
  3. **
  4. ** Program:        DTS.Lib
  5. ** File:        PPC.c
  6. ** Written by:  Eric Soldan
  7. **
  8. ** Copyright © 1992 Apple Computer, Inc.
  9. ** All rights reserved.
  10. **
  11. ** This is the only PPC code we have so far for this file.  Who knows if we'll do more...
  12. */
  13.  
  14.  
  15.  
  16. /*****************************************************************************/
  17.  
  18.  
  19.  
  20. #include "PPC.h"
  21. #include "Utilities.h"
  22.  
  23.  
  24.  
  25. /*****************************************************************************/
  26.  
  27.  
  28.  
  29. OSErr    DoIPCListPorts(short *sindx, short *reqCount, short *actCount,
  30.                        LocationNamePtr  loc,
  31.                        PortInfoArrayPtr retInfo,
  32.                        PPCFilterProcPtr filter)
  33. {
  34.     OSErr                err;
  35.     IPCListPortsPBRec    lpPBRec;
  36.     PPCPortRec            portRec;
  37.     PortInfoRec            info;
  38.     Boolean                keeper;
  39.     char                *cptr;
  40.     short                i;
  41.  
  42.     *actCount = 0;
  43.  
  44.     cptr = (char *)&lpPBRec;
  45.     for (i = 0; i < sizeof(IPCListPortsPBRec); ++i) cptr[i] = 0;
  46.  
  47.     portRec.nameScript = 0;
  48.     pcpy(portRec.name, "\p=");                    /* Match all names. */
  49.  
  50.     portRec.portKindSelector = ppcByString;
  51.     pcpy(portRec.u.portTypeStr, "\p=");            /* Match all names. */
  52.  
  53.     lpPBRec.requestCount = 1;
  54.     lpPBRec.portName     = &portRec;
  55.     lpPBRec.locationName = loc;
  56.     lpPBRec.bufferPtr    = &info;
  57.  
  58.     for (; *actCount < *reqCount;) {
  59.  
  60.         lpPBRec.startIndex = *sindx;
  61.         if (err = IPCListPortsSync(&lpPBRec)) return(err);    /* Call IPCListPorts synchronously. */
  62.  
  63.         ++*sindx;    /* We read it once.  Make sure we don't read it again. */
  64.  
  65.         if (!lpPBRec.actualCount) {        /* If this happens, we hit end of list. */
  66.             *reqCount = 0;                /* This is a flag stating that all are read. */
  67.             return(noErr);
  68.         }
  69.  
  70.         keeper = true;
  71.         if (filter)
  72.             keeper = (*filter)(loc, &info);
  73.         if (keeper) {
  74.             retInfo[*actCount] = info;
  75.             ++*actCount;
  76.         }
  77.     }
  78.  
  79.     return(noErr);
  80. }
  81.  
  82.  
  83.  
  84.